const path = require('path')
const CONFIG = require('../config.json')
const MOCK = CONFIG.MOCK
const APP__URL =
  process.env.NODE_ENV === 'production'
    ? `${CONFIG.APP__HOST__PRODUCT}:${CONFIG.APP__PORT__PRODUCT}`
    : `${CONFIG.APP__HOST__PROXY}:${CONFIG.APP__PORT__PROXY}`
const APP__URL__SERVER =
  process.env.NODE_ENV === 'production'
    ? `${CONFIG.APP__HOST__PROXY__SERVER}:${CONFIG.APP__PORT__PROXY__SERVER}`
    : `${CONFIG.APP__HOST__SERVER}:${CONFIG.APP__PORT__SERVER}`
const PATH_ROOT = path.join(__dirname, '../')

const PATH__UPLOAD = `${PATH_ROOT}/static/upload`
const PATH__UPLOAD__NEWS = `${PATH__UPLOAD}/news`
const PATH__UPLOAD__AVATAR = `${PATH__UPLOAD}/avatar`

const URL__STATIC = `${CONFIG.APP__HOST__PROXY}:${CONFIG.APP__PORT__PROXY__IMAGE}`
const URL__UPLOAD = `${URL__STATIC}/upload`
const URL__UPLOAD__NEWS = `${URL__UPLOAD}/news`
const URL__UPLOAD__AVATAR = `${URL__UPLOAD}/avatar`

module.exports = {
  APP__URL,
  APP__URL__SERVER,
  PATH_ROOT,
  PATH__UPLOAD__NEWS,
  PATH__UPLOAD__AVATAR,
  URL__STATIC,
  URL__UPLOAD__NEWS,
  URL__UPLOAD__AVATAR,
  MOCK
}
